package com.evenvi.myfistapp;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Vibrator;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import org.opencv.android.OpenCVLoader;


public class MainActivity extends AppCompatActivity {

    public static final String EXTRA_MESSAGE = "com.evenvi.myfirstapp.Message";
    private static final String CV_TAG = "OPENCV_TAG:";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    public void sendMessage(View view){
        Intent intent = new Intent(this, DisplayMessageActivity.class);
        EditText editText = (EditText)findViewById(R.id.editText4);
        String message = editText.getText().toString();
        intent.putExtra(EXTRA_MESSAGE, message);
        startActivity(intent);
    }

    public void startVibrator(View view){
        Vibrator vibrator = (Vibrator)this.getSystemService(this.VIBRATOR_SERVICE);
//        vibrator.vibrate(1000);
//        vibrator.vibrate(100);
//        vibrator.vibrate(20);

        long[] patter = {1000, 1000, 2000, 100, 50, 80};
        vibrator.vibrate(patter, -1);
    }

    public void startBascisView(View view){
        Intent intent = new Intent(this, basicView.class);
        startActivity(intent);
    }

    public void opencvButton(View view){

    }



    private void initLoadOpencv(){
        boolean success = OpenCVLoader.initDebug();
        if(success){
            Log.i(CV_TAG, "Opencv Libraries loaded...");
        }else {
            Toast.makeText(this.getApplicationContext(), "WARNING: Could not load opencv libraries", Toast.LENGTH_LONG).show();
        }
    }

}
